home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / progjour / 1990 / 05 / makeid.c < prev    next >
C/C++ Source or Header  |  1990-07-08  |  940b  |  53 lines

  1. /* makeid.c    creates a list of #define statements on stdout.  can be
  2.  *        redirected to a header file:
  3.  *
  4.  *        C> makeid strings.rsc > myincl.h
  5.  *
  6.  *    (c) Copyright 1990 Aspen Scientific
  7.  *    All Rights Reserved
  8.  */
  9.  
  10. #include <stdio.h>
  11. #include "resource.h"
  12.  
  13. void    fatal(char *str);
  14.  
  15. void
  16. main(int argc, char **argv)
  17. {
  18.     register int    i;
  19.     StringResource    *res;
  20.  
  21.     if (argc == 1)
  22.     {
  23.         fprintf(stderr, "usage:: makeid ResourceFile1 <file2> <file3> ..\n");
  24.         exit(1);
  25.     }
  26.     for (i=1; i < argc; ++i) {
  27.         res = LoadResources(argv[i]);
  28.  
  29.         if (res == NULL)
  30.             fatal("error loading strings.rsc");
  31.  
  32.         while (res) {
  33.             printf("#define\t%s\t\t%d\n",
  34.                 GetResourceName(res), GetResourceID(res));
  35. #ifdef DEBUG
  36.             printf("\t\"%s\"\n", GetResourceString(res));
  37. #endif
  38.             res = NextResource(res);
  39.         }
  40.  
  41.         FreeResources(res);
  42.     }
  43.  
  44.     exit(0);
  45. }
  46.  
  47. void
  48. fatal(char *str)
  49. {
  50.     fprintf(stderr, "fatal: %s\n", str);
  51.     exit(2);
  52. }
  53.